package sequencial;

//import java.io.*;

public class CircServer {

	public byte[][] circles(byte[][] pic, int IMG_SIZE) {

		byte[][] npic = new byte[IMG_SIZE][IMG_SIZE];

		int X = IMG_SIZE;
		int Y = IMG_SIZE;
		int[][] A = new int[X][Y]; // int[X][Y][R];
		int pixel;
		int r;
		int maxA = 0;

		for (int y = 0; y < Y; y++) {
			for (int x = 0; x < X; x++) {
				pixel = pic[x][y];
				if (pixel > 0) {
					// this point needs to be considered in the accumulator.
					// plug for x0,y0 and get r.
					for (int x0 = 0; x0 < X; x0++) {
						for (int y0 = 0; y0 < Y; y0++) {
							r = (int) Math.sqrt((x - x0) * (x - x0) + (y - y0)
									* (y - y0));
							if ((r >= 3) && (r < 50)) { // increment
														// accumulator;
								A[x0][y0]++;// A[x0][y0][r]++;
								if (A[x0][y0] > maxA)
									maxA = A[x0][y0];
							}
						}
					}

				}
			}
		}

		for (int y = 0; y < Y; y++)
			for (int x = 0; x < X; x++)
				npic[x][y] = (byte) ((A[x][y] * 127) / maxA);

		return (npic);
	}
}
